Trò chơi Pac-Man

20.582 lượt xem;
1 using UnityEngine;
2 using
System.Collections;
3
4 public
class PacdotSpawner : MonoBehaviour {
5
6     
public GameObject pacdot;
7     
public float interval;
8     
public float startOffset;
9
10     
private float startTime;
11
12     
// Use this for initialization
13     
void Start ()
14     {
15         startTime = Time.time + startOffset;
16     }
17     
18     
// Update is called once per frame
19     
void Update ()
20     {
21         
if(Time.time > startTime + interval)
22         {
23             GameObject obj = (GameObject)Instantiate(pacdot, transform.position, Quaternion.identity);
24             obj.transform.parent = transform;
25
26             startTime = Time.time;
27         }
28     }
29 }


Use this for initialization

Update is called once per frame



Gõ tìm kiếm nhanh...